import Vue from 'vue'
import VueRouter from 'vue-router'
const routerRePush = VueRouter.prototype.push
VueRouter.prototype.push = function (location) {
  return routerRePush.call(this, location).catch(error => error)
}
Vue.use(VueRouter)
// 导入一级layout组件
import layout from '@/views/layout'
// 导入路线编辑页面
import pathcompile from '@/views/pathcompile'
import picture from '@/views/picture'
import recharge from '@/views/recharge'
import record from '@/views/record'
import explain from '@/views/explain'
import execute from '@/views/execute'
import column from '@/views/column'

const routes = [
  // // 设置路由重定向 
  { path: "/", redirect: "/layout/picture" },
  // 一级路由layout
  {
    name: 'layout',
    path: '/layout',
    component: layout,
    // 二级路由
    children: [
      {
        name: 'picture',
        path: 'picture',
        component: picture,
      },//导入构图作为二级路由
      { name: 'pathcompile', path: 'pathcompile', component: pathcompile },//导入路线编辑作为二级路由
      { name: 'recharge', path: 'recharge', component: recharge },//导入充电点作为二级路由
      { name: 'record', path: 'record', component: record },//导入记录库位置作为二级路由
      { name: 'explain', path: 'explain', component: explain },//导入使用说明作为二级路由
      {name:'execute',path:'execute',component:execute},  //导入执行任务页面
      {name:'column',path:'column',component:column}   //导入列列表页面
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
